package com.bjpowernode.springboot.controller;

import com.bjpowernode.springboot.entity.User;
import com.bjpowernode.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {
    @Autowired
    private UserService userService; // 注入user对象的service接口

    @RequestMapping(value = "/queryUserById")
    @ResponseBody
    public User queryUserById(int id) {
        System.out.println(id);
        User user = userService.queryUserById(id); // 没有拿到数据？？？
        System.out.println(user);
        return user;
    }

    @RequestMapping(value = "/hello")
    @ResponseBody
    public String hello() {
        return "hello, mybatis";
    }
}
